package com.yiduo.outpost.core.model.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.yiduo.outpost.core.model.enums.PermissionLevel;
import com.yiduo.outpost.core.model.enums.PermissionType;
import com.yiduo.outpost.core.model.typehandlers.PermissionMappingTypeHandler;
import lombok.Data;

import java.time.Instant;

/**
 * 权限
 */
@Data
@TableName("ucenter_permission")
public class Permission {

    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * 权限名称
     */
    private String name;
    /**
     * 父级权限
     */
    private Long parentId;
    /**
     * 权限级别 1,2,3,4
     */
    private PermissionLevel level;
    /**
     * 权限对应的链接
     */
    @TableField(typeHandler = PermissionMappingTypeHandler.class)
    private PermissionMapping[] mapping;
    /**
     * 功能模块（前端）
     */
    private String module;
    /**
     * 数据权限: 0-操作权限  ,1-全部,2-自己,3-子集
     */
    private PermissionType permissionType;

    @TableField(fill = FieldFill.INSERT)
    private Instant createdAt;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Instant updatedAt;

}
